// pages/myself/shopcenter/shopcenter.js
const app = getApp()
var queryUrl = app.globalData.queryUrl;
var start;
var QQMapWX = require('../../../../utils/qqmap-wx-jssdk.min.js');
var qqmapsdk;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    curNav: 0,
    open: false,
    currentData: 0,
    textFlag: false,
    openId:'',
    shopId:'',
    text: "自今年以来，中国和俄罗斯在经贸合作上不断加深。上个月，中国宣布允许俄罗斯全境大豆出口至华。随后，该国大豆供应商向中国运送的首批4400吨大豆也已经成功抵华。在大豆对华出口顺利进行之时，俄罗斯又看向了中国另一大农产品市场,自今年以来，中国和俄罗斯在经贸合作上不断加深。上个月，中国宣布允许俄罗斯全境大豆出口至华。随后，该国大豆供应商向中国运送的首批4400吨大豆也已经成功抵华。在大豆对华出口顺利进行之时，俄罗斯又看向了中国另一大农产品市场",
    latitude: 24.4795100000,
    longitude: 118.0894800000,
    markers: [
      {
        id: 0,
        selectedTrade:'',
        latitude: 24.7555700000,
        longitude: 118.0824000000,
        iconPath: "../../../images/img6.png",
        width: 70,
        height: 70,
        callout: {

        }
      },
    ],
    head:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var shopId = options.shopId
    console.log(shopId)
    // var newShop = that.data.shopId
    that.setData({ shopId: shopId})
    try {
      var openId = wx.getStorageSync('openId')
    } catch (e) { }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // this.animation = wx.createAnimation();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    wx.request({
      url: queryUrl + 'selectShop',
      data: {
        // id: that.data.shopId, //传参
        id: 2,
        // shopId:that.data.shopId,
        // opendId: that.data.openId,
      },
      method: 'post',
      success: function (res) {
        console.log(res)
        that.setData({
          head: res.data.data.shop[0]
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //获取当前滑块的index
  bindchange: function (e) {
    let that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
  //点击切换，滑块index赋值
  checkCurrent: function (e) {
    let that = this;
    var current = that.data.currentData
    var en = e.target.dataset.current
    if (current === en) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
    }
    if (en == "2") {
      let that = this;
      wx.request({
        url: queryUrl + 'recruit/select',
        data: {
          // shopId:that.data.shopId
          shopId:2
        },
        method: 'post',
        success: function (res) {
          console.log(res.data)
          // that.setData({
          //   posits: res.data.data.recruit
          // })
        }
      })
    }
    if (en == "3") {
      let that = this;
      console.log(shopId)
      wx.request({
        url: queryUrl + 'selectProduct',
        data: {
          shopId: "2",
        },
        method: 'post',
        success: function (res) {
          console.log(res)
        }
      })
    }
  },
  switchRightTab: function (e) {
    let id = e.target.dataset.id;
    console.log(id);
    this.setData({
      curNav: id
    })
  },
  // 返回上一页
  navigateBack: function () {
    wx.switchTab({
      url: "../../index/index"
    });
  },
  activeGo: function () {
    wx.navigateTo({
      url: '../../member/active/active',
    })
  },
  goOoder: function () {
    wx.navigateTo({
      url: '../purchase/purchase',
    })
  },
  goSum: function () {
    wx.navigateTo({
      url: '../sumResume/sumResume',
    })
  },
  goLibry: function () {
    wx.navigateTo({
      url: '../resLibrary/resLibrary',
    })
  },
  toaddress: function (e) {
    console.log(e)
    var id = e.markerId
    console.log(id)
  },
  goAdd: function (e) {
    var that = this
    var shopId = that.data.shopId
    console.log(shopId)
    wx.navigateTo({
      url: '../addposition/addposition?shopId=' + shopId,
    })
  },
  goDetails: function () {
    wx.navigateTo({
      url: '../details/details',
    })
  },
  goSinfor: function () {
    wx.navigateTo({
      url: '../../../setUp/shopInfor/shopInfor',
    })
  },
  goSauthen: function () {
    wx.navigateTo({
      url: '../../../setUp/shopAuthen/shopAuthen',
    })
  },
  goVideo:function(){
    wx.switchTab({
      url: '../../../video/add/add',
    })
  },
  addheight: function () {
    this.setData({
      textFlag: !this.data.textFlag
    })
  },
  tradeShow: function (e) {
    console.log(e);
    this.setData({
      isRuleTrue: true
    })
    // this.animation.translate(-240, 0).step()
    // this.setData({ animation: this.animation.export() })
  },
  success: function (e) {
    var val = e.currentTarget.dataset.val
    this.setData({
      isRuleTrue: false,
      selectedTrade: val
    })
    // this.animation.translate(323, 0).step()
    // this.setData({ animation: this.animation.export() })
  }
})